import { request, propsNotEmpty } from './utils';

async function getUrlByToken(token, options) {
  propsNotEmpty(options, ['API_BASE_URL', 'APP_KEY']);

  const {
    API_BASE_URL,
    APP_KEY,
    redirectUrl,
    HEADERS_CONFIG: headersConfig
  } = options;
  try {
    const data = await request(`${API_BASE_URL}wechatMiniApp/getUrlByToken`, {
      token,
      appKey: APP_KEY,
      redirectUrl
    }, 'GET', headersConfig);
    return data;
  } catch (error) {
    throw error
  }
}

export default getUrlByToken;